/*   1:    */ package org.intellij.plugins.relaxNG.compact.psi.impl;
/*   2:    */ 
/*   3:    */

import com.intellij.extapi.psi.ASTWrapperPsiElement;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.ResolveState;
import com.intellij.psi.scope.PsiScopeProcessor;
import com.intellij.psi.scope.PsiScopeProcessor.Event;
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.tree.TokenSet;
import com.intellij.util.IncorrectOperationException;
import org.intellij.plugins.relaxNG.compact.RncElementTypes;
import org.intellij.plugins.relaxNG.compact.psi.RncElement;
import org.intellij.plugins.relaxNG.compact.psi.RncElementVisitor;
import org.intellij.plugins.relaxNG.model.CommonElement;
import org.jetbrains.annotations.NotNull;

/*   4:    */
/*   5:    */
/*   6:    */
/*   7:    */
/*   8:    */
/*   9:    */
/*  10:    */
/*  11:    */
/*  12:    */
/*  13:    */
/*  14:    */
/*  15:    */
/*  16:    */
/*  17:    */
/*  18:    */
/*  19:    */ 
/*  20:    */ public abstract class RncElementImpl
/*  21:    */   extends ASTWrapperPsiElement
/*  22:    */   implements RncElement, CommonElement<RncElement>
/*  23:    */ {
/*  24: 34 */   private static final TokenSet e = TokenSet.create(new IElementType[] { RncElementTypes.START, RncElementTypes.DEFINE, RncElementTypes.DIV, RncElementTypes.GRAMMAR_PATTERN, RncElementTypes.PATTERN, RncElementTypes.INCLUDE });
/*  25:    */   
/*  26:    */   public RncElementImpl(ASTNode paramASTNode)
/*  27:    */   {
/*  28: 42 */     super(paramASTNode);
/*  29:    */   }
/*  30:    */   
/*  31:    */   public String toString()
/*  32:    */   {
/*  33: 46 */     return getNode().getElementType().toString();
/*  34:    */   }
/*  35:    */   
/*  36:    */   public void delete()
/*  37:    */     throws IncorrectOperationException
/*  38:    */   {
/*  39: 51 */     getNode().getTreeParent().removeChild(getNode());
/*  40:    */   }
/*  41:    */   
/*  42:    */   public PsiElement add(@NotNull PsiElement paramPsiElement)
/*  43:    */     throws IncorrectOperationException
/*  44:    */   {
/*  45: 56 */     if (paramPsiElement == null) {
/*  46: 56 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/intellij/plugins/relaxNG/compact/psi/impl/RncElementImpl", "add" }));
/*  47:    */     }
/*  48: 56 */     ASTNode localASTNode = paramPsiElement.getNode();
/*  49: 57 */     assert (localASTNode != null);
/*  50:    */     
/*  51: 59 */     getNode().addChild(localASTNode);
/*  52: 60 */     PsiElement localPsiElement = getNode().getLastChildNode().getPsi();
/*  53:    */     
/*  54: 62 */     assert (localPsiElement.getClass() == paramPsiElement.getClass());
/*  55: 63 */     return localPsiElement;
/*  56:    */   }
/*  57:    */   
/*  58:    */   public PsiElement addBefore(@NotNull PsiElement paramPsiElement1, PsiElement paramPsiElement2)
/*  59:    */     throws IncorrectOperationException
/*  60:    */   {
/*  61: 68 */     if (paramPsiElement1 == null) {
/*  62: 68 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/intellij/plugins/relaxNG/compact/psi/impl/RncElementImpl", "addBefore" }));
/*  63:    */     }
/*  64: 68 */     ASTNode localASTNode1 = paramPsiElement1.getNode();
/*  65: 69 */     assert (localASTNode1 != null);
/*  66:    */     
/*  67: 71 */     ASTNode localASTNode2 = paramPsiElement2.getNode();
/*  68: 72 */     assert (localASTNode2 != null);
/*  69:    */     
/*  70: 74 */     getNode().addChild(localASTNode1, localASTNode2);
/*  71: 75 */     PsiElement localPsiElement = localASTNode2.getTreePrev().getPsi();
/*  72:    */     
/*  73: 77 */     assert (localPsiElement.getClass() == paramPsiElement1.getClass());
/*  74: 78 */     return localPsiElement;
/*  75:    */   }
/*  76:    */   
/*  77:    */   public PsiElement addAfter(@NotNull PsiElement paramPsiElement1, PsiElement paramPsiElement2)
/*  78:    */     throws IncorrectOperationException
/*  79:    */   {
/*  80: 83 */     if (paramPsiElement1 == null) {
/*  81: 83 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/intellij/plugins/relaxNG/compact/psi/impl/RncElementImpl", "addAfter" }));
/*  82:    */     }
/*  83: 83 */     ASTNode localASTNode1 = paramPsiElement2.getNode();
/*  84: 84 */     assert (localASTNode1 != null);
/*  85:    */     
/*  86: 86 */     ASTNode localASTNode2 = localASTNode1.getTreeNext();
/*  87: 87 */     if (localASTNode2 == null) {
/*  88: 88 */       return add(paramPsiElement1);
/*  89:    */     }
/*  90: 90 */     return addBefore(paramPsiElement1, localASTNode2.getPsi());
/*  91:    */   }
/*  92:    */   
/*  93:    */   public final void accept(@NotNull PsiElementVisitor paramPsiElementVisitor)
/*  94:    */   {
/*  95: 95 */     if (paramPsiElementVisitor == null) {
/*  96: 95 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/intellij/plugins/relaxNG/compact/psi/impl/RncElementImpl", "accept" }));
/*  97:    */     }
/*  98: 95 */     if ((paramPsiElementVisitor instanceof RncElementVisitor)) {
/*  99: 96 */       accept((RncElementVisitor)paramPsiElementVisitor);
/* 100:    */     } else {
/* 101: 98 */       paramPsiElementVisitor.visitElement(this);
/* 102:    */     }
/* 103:    */   }
/* 104:    */   
/* 105:    */   public boolean processDeclarations(@NotNull PsiScopeProcessor paramPsiScopeProcessor, @NotNull ResolveState paramResolveState, PsiElement paramPsiElement1, @NotNull PsiElement paramPsiElement2)
/* 106:    */   {
/* 107:104 */     if (paramPsiScopeProcessor == null) {
/* 108:104 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/intellij/plugins/relaxNG/compact/psi/impl/RncElementImpl", "processDeclarations" }));
/* 109:    */     }
/* 110:104 */     if (paramResolveState == null) {
/* 111:104 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "1", "org/intellij/plugins/relaxNG/compact/psi/impl/RncElementImpl", "processDeclarations" }));
/* 112:    */     }
/* 113:104 */     if (paramPsiElement2 == null) {
/* 114:104 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "3", "org/intellij/plugins/relaxNG/compact/psi/impl/RncElementImpl", "processDeclarations" }));
/* 115:    */     }
/* 116:104 */     ASTNode localASTNode1 = getNode();
/* 117:    */     
/* 118:106 */     ASTNode[] arrayOfASTNode1 = localASTNode1.getChildren(e);
/* 119:107 */     paramPsiScopeProcessor.handleEvent(PsiScopeProcessor.Event.SET_DECLARATION_HOLDER, this);
/* 120:108 */     for (ASTNode localASTNode2 : arrayOfASTNode1) {
/* 121:109 */       if (!paramPsiScopeProcessor.execute(localASTNode2.getPsi(), paramResolveState)) {
/* 122:110 */         return false;
/* 123:    */       }
/* 124:    */     }
/* 125:113 */     paramPsiScopeProcessor.handleEvent(PsiScopeProcessor.Event.SET_DECLARATION_HOLDER, null);
/* 126:114 */     return true;
/* 127:    */   }
/* 128:    */   
/* 129:    */   public abstract void accept(@NotNull RncElementVisitor paramRncElementVisitor);
/* 130:    */   
/* 131:    */   public void accept(CommonElement.Visitor paramVisitor)
/* 132:    */   {
/* 133:120 */     paramVisitor.visitElement(this);
/* 134:    */   }
/* 135:    */   
/* 136:    */   public void acceptChildren(CommonElement.Visitor paramVisitor)
/* 137:    */   {
/* 138:124 */     PsiElement[] arrayOfPsiElement = getChildren();
/* 139:126 */     for (int i = 0; i < arrayOfPsiElement.length; i++)
/* 140:    */     {
/* 141:127 */       PsiElement localPsiElement = arrayOfPsiElement[i];
/* 142:128 */       if ((localPsiElement instanceof CommonElement)) {
/* 143:129 */         ((CommonElement)localPsiElement).accept(paramVisitor);
/* 144:    */       }
/* 145:    */     }
/* 146:    */   }
/* 147:    */   
/* 148:    */   public RncElement getPsiElement()
/* 149:    */   {
/* 150:135 */     return this;
/* 151:    */   }
/* 152:    */ }



/* Location:           E:\idea\

 * Qualified Name:     org.intellij.plugins.relaxNG.compact.psi.impl.RncElementImpl

 * JD-Core Version:    0.7.0.1

 */